package com.zhkc.iess.system.controller;

import com.zhkc.iess.model.client.feign.Test01Feign;
import com.zhkc.iess.system.dto.UserDTO;
import com.zhkc.iess.system.service.TestService;
import com.zhkc.iess.system.service.UserService;
import com.zhkc.iess.system.vo.TestVO;
import com.zhkc.iess.system.vo.UserDetailsVO;
import com.zhkc.iess.system.vo.UserVO;
import com.zhkc.wisdom.common.base.model.LoginContextInfo;
import com.zhkc.wisdom.common.pojo.vo.ComboxVO;
import com.zhkc.wisdom.common.pojo.vo.ResultVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.List;

@RestController
@Tag(name = "TEST类", description = "TEST类描述")
@Slf4j
public class Test02Controller {

    @Autowired
    private TestService testService;

    @Autowired
    private Test01Feign test01Feign;


    @Autowired
    private UserService userService;

    @Operation(summary = "测试", description = "测试方法")
    @GetMapping("/qwe/abc/test")
    public ResultVO<String> getMark() {
        ResultVO<ComboxVO> mark = test01Feign.getMark();
//        System.out.println("mark----------: " + mark);

        TestVO model = new TestVO();
        model.setTest01(LocalDateTime.now());
        LoginContextInfo testInfo = testService.getTestInfo(model, "1");
        System.out.println("获取当----------: " + testInfo.getOrgId());
        testService.deleteCache();
        return ResultVO.success("1");

    }

    @Operation(summary = "修改用户（加密）", description = "修改用户")
    @PostMapping("/api/v1/pass/system/user/update")
    public ResultVO<Void> updateInfo(@RequestBody UserDTO dto) {
        userService.updateInfo(dto);
        return ResultVO.success();

    }

    @Operation(summary = "获取用户列表(解密,脱敏)", description = "获取用户列表")
    @GetMapping("/api/v1/pass/system/user/list")
    public ResultVO<List<UserVO>> list() {
        return ResultVO.success(userService.userList());
    }


    @Operation(summary = "获取用户详细信息(解密,不脱敏)", description = "获取用户详细信息")
    @GetMapping("/api/v1/pass/system/user/details")
    public ResultVO<UserDetailsVO> details() {
        return ResultVO.success(userService.details());
    }


}
